package communi;

import java.util.concurrent.ExecutorService;

import static java.util.concurrent.Executors.newFixedThreadPool;

/**
 * @author Mark
 * @date 2020/5/24 12:49
 * @description 线程池
 */
public class ThreadPool {
    public static void main(String[] args) {

        ExecutorService service = newFixedThreadPool(10);
        service.execute(new MyThreadPool());
        service.execute(new MyThreadPool());
        service.execute(new MyThreadPool());
        service.execute(new MyThreadPool());
        service.execute(new MyThreadPool());
        service.execute(new MyThreadPool());
        service.shutdown();
    }
}

class MyThreadPool implements Runnable {

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }

}
